﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Windows.Media;
using ThreeByte.ActiveDeck.Content;

namespace ThreeByte.ActiveDeck.Converters
{
    public class LayoutOrientationToVisibilityConverter : IValueConverter
    {
        public Visibility Portrait { get; set; }
        public Visibility LandscapeLeft { get; set; }
        public Visibility LandscapeRight { get; set; }
        public Visibility UpsideDown { get; set; }

        //Must explicitly set values that you want visible
        public LayoutOrientationToVisibilityConverter() {
            Portrait = Visibility.Collapsed;
            LandscapeLeft = Visibility.Collapsed;
            LandscapeRight = Visibility.Collapsed;
            UpsideDown = Visibility.Collapsed;
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            
            Orientation o = Orientation.Portrait;
            if(value is Orientation) {
                o = (Orientation)value;
            }

            switch(o){
                case Orientation.LandscapeLeft:
                    return LandscapeLeft;
                case Orientation.LandscapeRight:
                    return LandscapeRight;
                case Orientation.UpsideDown:
                    return UpsideDown;
                default: return Portrait;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            throw new Exception("Cannot convert back from LayoutOrientationToVisibilityConverter");
        }
    }
   
}
